package com.zyf.chapter01.principle.LOD.refactor;

import com.zyf.chapter01.principle.LOD.utils.Html;

/**
 * 通过一个工厂方法来创建Document
 * @author yifeng
 */
public class DocumentFactory {
    private HtmlDownloader downloader;

    public DocumentFactory(HtmlDownloader downloader) {
        this.downloader = downloader;
    }

    public Document createDocument(String url) {
        Html html = downloader.downloadHtml(url);
        return new Document(html, url);
    }
}
